package com.iwhalecloud.bss.kite.cucc.web.service.bigdata.vo;

import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;

import java.io.Serializable;
import java.util.Map;
import java.util.Objects;

public class OppoProdAttr implements Serializable {
    private String attrCode;
    private String attrName;
    private String attrValCodes;
    private Map<String,String>  attrValues;
    private String valueType;
    private String groupId;
    private String attrValue;
    private String attrValueDesc;

    public String getGroupId() {
        return groupId;
    }

    public void setGroupId(String groupId) {
        this.groupId = groupId;
    }

    public String getAttrCode() {
        return attrCode;
    }

    public void setAttrCode(String attrCode) {
        this.attrCode = attrCode;
    }

    public String getAttrName() {
        return attrName;
    }

    public void setAttrName(String attrName) {
        this.attrName = attrName;
    }

    public String getAttrValCodes() {
        return attrValCodes;
    }

    public void setAttrValCodes(String attrValCodes) {
        this.attrValCodes = attrValCodes;
    }

    public String getValueType() {
        return valueType;
    }

    public void setValueType(String valueType) {
        this.valueType = valueType;
    }

    public Map<String, String> getAttrValues() {
        return attrValues;
    }

    public void setAttrValues(Map<String, String> attrValues) {
        this.attrValues = attrValues;
        this.setAttrValueDesc(getAttrValueDescFromYx(attrValues));
        this.setAttrValue(getAttrValueFromYx(attrValues));
    }

    public String getAttrValue() {
        return attrValue;
    }

    public void setAttrValue(String attrValue) {
        this.attrValue = attrValue;
    }

    public String getAttrValueDesc() {
        return attrValueDesc;
    }

    public void setAttrValueDesc(String attrValueDesc) {
        this.attrValueDesc = attrValueDesc;
    }
    private String getAttrValueFromYx(Map<String,String> attrValues){
        //若为输入框类型取valueCode取不到 改取valueName
        if(Objects.nonNull(attrValues)){
            if(KiteStringUtils.isNotEmpty(attrValues.get("valueCode"))){
                return attrValues.getOrDefault("valueCode","");
            }else if(KiteStringUtils.isNotEmpty(attrValues.get("valueName"))){
                return attrValues.getOrDefault("valueName","");
            }

        }
        return "";
    }
    private String getAttrValueDescFromYx(Map<String,String> attrValues){
        if(Objects.nonNull(attrValues)){
            return attrValues.getOrDefault("valueName","");
        }
        return "";
    }
}
